package frame.laxcen.response;

import frame.laxcen.BaseFrame;
import frame.laxcen.exception.IllegalFrameFormatException;
import frame.laxcen.util.FrameReader;

import java.util.HashMap;
import java.util.Map;

// 停止读写器所有的 RFID 操作的返回值
public class Response_0010_FF extends BaseFrame implements IResponse {

    public Response_0010_FF(BaseFrame baseFrame) throws IllegalFrameFormatException {

        initialize(baseFrame.FrameBytes);
    }

    public Response_0010_FF(byte[] bytes) throws IllegalFrameFormatException {

        initialize(bytes);
    }

    @Override
    public Map<String, String> explainToMap() throws IllegalFrameFormatException {

        Map<String, String> result = new HashMap<>();

        try {

            FrameReader reader = new FrameReader(this);

            // 查询结果

            switch(reader.readU8()) {

                case 0: result.put("查询结果", "停止成功"); break;
                case 1: result.put("查询结果", "系统错误"); break;
            }

        } catch (Exception e) {

            e.printStackTrace();

            throw new IllegalFrameFormatException(e.getMessage());
        }

        return result;
    }
}
